
cc.Class({
    extends: cc.Component,

    properties: {
      
    },


    onLoad () {
        this.init()
    },

    
    init (){
        this.node.active = true
        this.isDie = false
        this.node.setPosition(cc.v2(0,-350))
        this.hreoStrong = false // 战机无敌
        this.node.zIndex = 2
        // this.normal()
    },



    onCollisionEnter: function (other, self) {  
        if(other.tag < 10){
            var js = other.node.getComponent('enemy_' + other.tag)
            if(self.tag == 777 && !this.isDie && !js.isDie && !this.hreoStrong){
                this.die()
            }
        } 

         // 实现道具技能
        if(other.tag > 1000){
            if(other.tag == 1001)data.addBullet(2)
            if(other.tag == 1002){
                data.buttetType = 1
                data.buttetAtk = 2
            }
            if(other.tag == 1003)data.addBullet(4)
           
            game.delPrefab(other.node, other.tag)
            game.playing.skillProgress.getComponent("skillProgress").createSkillProgress(other.tag)
        }

    },



    normal(){
        var anim = this.getComponent(cc.Animation)
        anim.play('hreo')
    },


     
    rebirth(){
        game.gameStatus = 1
        this.isDie = false

        //复活后5秒无敌
        this.hreoStrong = true
        this.scheduleOnce(function(){
            this.hreoStrong = false
        }.bind(this), 5);

    },



    die(){
        this.isDie = true
        game.gameStatus = 3
        this.scheduleOnce(function(){
            game.hreoRebirth.active = true
        }.bind(this),1);
        //var anim = this.getComponent(cc.Animation)
        // anim.play('hreo_Die')
        // anim.over = function(){
        //     game.playHreoDieSound()
        //     this.node.active = false
        //     game.gameEnd()
        // }.bind(this)
        // game.gameEnd()
    },


    update (dt) {},


});
